package com.ydgk.dao;

import com.ydgk.bean.Address;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface AddressMapper {
    @Insert("insert into address values(#{adid},#{consignee},#{cphone},#{address},#{postcode},#{ar_arid},#{u_uid},#{ispretermission})")
    void insert(Address address);

    @Select("select * from address where u_uid = #{uid}")
    List<Address> getAdd(int uid);

    @Delete("delete from address where adid = #{adid}")
    void deleteByid(Integer adid);

    @Select("select * from address where adid = #{adid}")
    Address findById(Integer adid);

    @Update("update address set consignee = #{consignee}, cphone = #{cphone}, address = #{address}, postcode = #{postcode}, ar_arid = #{ar_arid}, ispretermission = #{ispretermission} where adid = #{adid}")
    void updateById(Address address);

    @Select("select count(*) from address where u_uid = #{uid}")
    int getAddCount(Integer uid);

    @Update("update address set ispretermission = 0")
    void setIspreFalse();

    @Update("update address set ispretermission = 1 where adid = #{adid}")
    void setIspreTrueById(Integer adid);
}
